<%@ page language="java" pageEncoding="UTF-8"
	contentType="text/html;charset=UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	request.setAttribute("basePath", basePath);
%>
<!DOCTYPE>
<html>
<head>
<title>明细信息</title>
	<%@ include file="/resources/js/easyui/taglibs.jsp"%>
	<%@ include file="/resources/js/easyui/_easyui.jsp"%>
	<%@ include file="/resources/js/easyui/_message.jsp"%>
	<%@ include file="/resources/js/easyui/_viewJS.jsp"%>
</head>

<body class="easyui-layout">
	<form id="editform">
		<table class="tableForm" style="width: 100%;">
			<tr>
				<th align="right" valign="top"><span class="redStart">*</span><label>父级权限：</label></th>
				<td><select class="easyui-combobox easyui-textbox"
					style="width:200px;" name="pmoduleid" data-options="required:true">
					<c:forEach items="${parentModuleList}" var="parent"
							   varStatus="status">
						<option value="${parent.moduleid }" ${parent.moduleid == module.pmoduleid ? "selected" : ""}>${parent.textCN }</option>

						<c:forEach items="${parent.childModules}" var="childModue" varStatus="status">
							<option value="${childModue.moduleid }" ${childModue.moduleid == module.pmoduleid ? "selected" : ""}>-${childModue.textCN }</option>

							<c:forEach items="${childModue.childModules}" var="childModuechild" varStatus="status">
								<option value="${childModuechild.moduleid }" ${childModuechild.moduleid == module.pmoduleid ? "selected" : ""}>--${childModuechild.textCN }</option>
							</c:forEach>

						</c:forEach>

					</c:forEach>

				</select></td>
			</tr>

			<tr>
				<th align="right" valign="top"><span class="redStart">*</span><label>权限名称（中文）：</label></th>
				<td><input class="easyui-validatebox easyui-textbox"
					name="namecn" value="${module.namecn }" style="width:200px"
					data-options="required:true,validType:'chinese'" /></td>
			</tr>

			<tr>
				<th align="right" valign="top"><span class="redStart">*</span><label>权限名称（英文）：</label></th>
				<td><input class="easyui-validatebox easyui-textbox"
					name="sname" value="${module.sname }" style="width:200px"
					data-options="required:true,validType:'english'" /></td>
			</tr>

			<tr>
				<th align="right" valign="top"><span class="redStart">*</span><label>url：</label></th>
				<td><input class="easyui-validatebox easyui-textbox" name="url"
					value="${module.url }" style="width:200px"
					data-options="required:true" /></td>
			</tr>

			<tr>
				<th align="right" valign="top"><label>权限属性：</label></th>
				<td><input class="easyui-validatebox easyui-textbox"
					value="${module.attribute }" name="attribute"
					style="width:200px;height:60px" data-options="multiline:true"></td>
			</tr>

			<tr>
				<th align="right" valign="top"><label>备注：</label></th>
				<td><input class="easyui-textbox" name="remark"
					value="${module.remark }" data-options="multiline:true"
					style="width:200px;height:60px;"></td>
			</tr>

			<tr>
				<th align="right" valign="top"><label>权限作用域：</label></th>
				<td><input type="radio" name="ntype" value="1"
					<c:if test="${module.ntype == 1 }">checked="checked"</c:if>>PC端
					<input type="radio" name="ntype" value="2"
					<c:if test="${module.ntype == 2 }">checked="checked"</c:if>>微信端
					<input type="radio" name="ntype" value="3"
					<c:if test="${module.ntype == 3 }">checked="checked"</c:if>>APP端
					<input type="radio" name="ntype" value="4"
						   <c:if test="${module.ntype == 4 }">checked="checked"</c:if>>操作权限
				</td>
			</tr>
			<input type="hidden" name="moduleid" value="${module.moduleid}" />
		</table>

	</form>

	<script type="application/javascript">
		
    function edit(){
        if($("#editform").form('validate')){
            $.ajax({
                url:'${basePath}web/module/eidtModule',
                type : 'POST',
                data : $("#editform").serialize(),
                async : false, //默认为true 异步
                traditional:true,
                error: function (response) {
                    ViewHelper.func.ajaxErrorMessage(response);
                },
                success: function (ret) {
                    if(ret.result) {
                        $.messager.alert('提示信息！',ret.info,'info');
                        parent.view.closeEditWin(1);
                        $("#editform").form('clear');
                    }else{
                        $.messager.alert('提示','保存失败!','error');
                    }
                }
            });
        }
    }
	
	$.extend($.fn.validatebox.defaults.rules, {
		chinese: {
			 validator : function(value) {
                 return /^[\u0391-\uFFE5]+$/.test(value);
             },
             message : '请输入正确的中文名称'
		},
		english:{
			validator: function(value){
				return /^[a-zA-Z]+$/.test(value);
			},
			message: '请输入正确的英文名称'
		}
		
	});

	</script>
</body>
</html>
